package main

import (
	"encoding/base64"
	"gin/tai/voice"
	uuid "github.com/satori/go.uuid"
	"github.com/spf13/viper"
	"io/ioutil"
	"os"
)

func main() {
	InitConfig()
	workDir, _ := os.Getwd()

	//var fbytes = make([]byte,fptr.)
	//fptr.Read()
	fcBytes, err := ioutil.ReadFile(workDir + "/tai/test/SentenceRecognition/1.mp3")
	if err != nil {
		println(err.Error())
		return
	}
	fContentStr := base64.StdEncoding.EncodeToString(fcBytes)

	var rawLength int64
	rawLength = int64(len(fcBytes))
	res, err := voice.SentenceRecognition(0, 1, uuid.NewV4().String(), "mp3", "", fContentStr, rawLength)
	if err != nil {
		println(err.Error())
		return
	}
	println(*res.Response.Result)
}

func InitConfig() {
	workDir, _ := os.Getwd()
	viper.SetConfigName("application")
	viper.SetConfigType("yml")
	viper.AddConfigPath(workDir + "/config")
	err := viper.ReadInConfig()
	if err != nil {
		panic(err)
	}
}
